class CreateTrainRouters < ActiveRecord::Migration
  def self.up
    create_table :train_routers do |t|
      t.integer   :train_id                                                     #列车id
      t.integer   :router_id                                                    #交路id
      t.integer   :sequence                                                     #存储交路的组合排序，从零开始，如：  0:D76、D77  1:D78、D75
      
      t.integer   :is_locked     ,:limit => 1 ,:default => 0                    #锁定 1为True 0为False
      t.integer   :lock_version  ,:default => 0                                 #乐观锁
      t.timestamps
    end

    TrainRouter.create(:train_id => 1,:router_id => 1)


  end

  def self.down
    drop_table :train_routers
  end
end
